<?php 
	header("Content-type: application/json; charset=utf-8");
?>
<?php
	include("include1.php");
	$CVid = mysql_real_escape_string($_REQUEST["filter"]["filters"][0]["value"]);
	$verb = $_SERVER["REQUEST_METHOD"];
	
	//ini_set('default_charset','utf-8');	
		/*/
		$sql = "select kq.*, l.TenLoai
				from
				(SELECT dm.id as DMid, dm.MHDM, dm.MaVT, g.TenVT, g.DVT, g.GiaGoc, dm.HaoPhiVatTu, (select substring(dm.MaVT,1,1)) as Loai
				FROM `dinhmuc` dm join gia g on g.MaVT=dm.MaVT 
				WHERE MHDM='". $CVid ."') kq
				join loaivattu l on l.MaLoai=kq.Loai";
		/*/
		
		$sql = "select kl.MaCV, g.MaVT, g.TenVT, g.DVT, g.GiaGoc, dm.HaoPhiVatTu, (select substring(dm.MaVT,1,1)) as Loai, l.TenLoai
from ((khoiluongmoithau kl join dinhmuc dm on dm.MHDM=kl.MaCV) 
	left join gia g on dm.MaVT=g.maVT) join loaivattu l
        	on l.MaLoai=(select substring(dm.MaVT,1,1))
where MaCV='". $CVid ."'";
		//echo $sql;
		$arr = array();
		
		$rs = mysql_query($sql);
		//$rs = mysql_query("select * from khoiluongmoithau");
		while($obj = mysql_fetch_object($rs))
		{
				$arr[] = $obj;
				
		}
		
		echo "{\"data\":" . json_encode($arr , JSON_UNESCAPED_UNICODE) . "}";
	//
	
	
?>